package com.leil.java8.递归;

/**
 * 斐波那契数列
 *  f(n) = f(n - 1) + f(n - 2) (n >= 3)
 */
public class RecursiveFibonacci {

    IntCall fib;

    RecursiveFibonacci() {
        fib = n -> n == 0 ? 0 :
                n == 1 ? 1 : fib.call(n - 1) + fib.call(n - 2);
    }

    public static void main(String[] args) {
        RecursiveFibonacci rec = new RecursiveFibonacci();

        System.out.println(rec.fib.call(5));
    }

}
